//
//  TL_UserDataTableViewCell.m
//  WXReader
//
//  Created by Andrew on 2020/5/30.
//  Copyright © 2020 Andrew. All rights reserved.
//

#import "TL_UserDataTableViewCell.h"

#import "TL_UserDataModel.h"

@implementation TL_UserDataTableViewCell {
    UILabel *cellTitleLabel;
    UILabel *cellDescTitleLab;
    UIImageView *connerImageView;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = kWhiteColor;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews
{
    
    cellTitleLabel = [[UILabel alloc] init];
    cellTitleLabel.textColor = kBlackColor;
    cellTitleLabel.font = kMainFont;
    cellTitleLabel.textAlignment = NSTextAlignmentLeft;
    [self.contentView addSubview:cellTitleLabel];
    
    [cellTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(self.contentView);
        make.left.mas_equalTo(kMargin);
        make.width.mas_equalTo(SCREEN_WIDTH / 2);
        make.height.mas_equalTo(56);
    }];
    
    connerImageView = [[UIImageView alloc] init];
    connerImageView.image = [UIImage imageNamed:@"public_more"];
    [self.contentView addSubview:connerImageView];
    
    [connerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.width.mas_equalTo(10);
        make.height.mas_equalTo(10);
    }];
    
    UILabel *titleLab = [[UILabel alloc] init];
    titleLab.font = SYSTEM_FONT(12);
    titleLab.textAlignment = NSTextAlignmentRight;
    titleLab.textColor = kGrayTextColor;
    [self.contentView addSubview:titleLab];
    cellDescTitleLab = titleLab;
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(cellTitleLabel.mas_right);
        make.right.mas_equalTo(connerImageView.mas_left).offset(-5);
        make.top.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView);
    }];
}

- (void)setTitle:(NSString*)title andDesc:(NSString*)desc andIsShowMore:(BOOL)isShowMore{
    cellTitleLabel.text = title;
    if ([desc isEqualToString:@""]) {
        cellDescTitleLab.hidden = YES;
    }else{
        cellDescTitleLab.hidden = NO;
        cellDescTitleLab.text = desc;
    }
    connerImageView.hidden = !isShowMore;
}
@end
